import mongoose from 'mongoose';
import { formatDateByNow } from '~/utils/util.date';

export interface IUserApply extends mongoose.Document {
	userId: mongoose.Schema.Types.ObjectId;
	url: string;
	email: string;
	reason: string;
	createdAt?: string;
	updatedAt?: string;
}

// 用户申请收录
const UserApplySchema = new mongoose.Schema<IUserApply>(
	{
		userId: {
			type: mongoose.Schema.Types.ObjectId,
			required: true,
		},
		url: {
			type: String,
			required: true,
		},
		email: {
			type: String,
			required: true,
		},
		reason: {
			type: String,
			required: true,
		},
		createdAt: {
			type: String,
			default: formatDateByNow(),
		},
		updatedAt: {
			type: String,
			default: formatDateByNow(),
		},
	},
	{
		collection: 'user_apply',
	}
);

export const UserApplyModel = mongoose.model('UserApply', UserApplySchema);
